
import { useEffect, useState } from "react"
import { fetchChannelAPI } from "../../apis/list"
import type { ChannelItem } from '@/apis/list';
const useTabs = () => {
    const [channels, setChannels] = useState<ChannelItem[]>([])

    useEffect(() => {
        async function getChannels() {
            try {
                const res = await fetchChannelAPI();
                setChannels(res.data.data.channels)
            } catch (error) {
                throw new Error("fetch channel error")
            }
        }
        getChannels();
    }, [])

    return {
        channels
    }
}

export { useTabs }